fix: verify buyer ownership before entering the setinvoice flow#833
Conversation
The addInvoicePHI handler and the setinvoice_ action looked up the order by the id carried in the callback data and then entered the invoice flow without checking that the caller is the order's buyer. Add an explicit check that ctx.user is the buyer in both entry points, so only the buyer can set or replace the payout invoice of their order. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAuthorization checks are added to two invoice-related entry points: the ChangesInvoice Buyer Authorization
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed due to a network error. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
The
addInvoicePHIhandler (bot/commands.ts) and thesetinvoice_action (bot/start.ts) looked up the order using the id carried in the inline-button callback data and then entered the invoice flow, without checking that the caller is the order's buyer. This adds an explicit ownership check in both entry points so only the buyer can set or replace the payout invoice of their order.Why
The payout invoice is the destination of the order's funds, so only the buyer should be able to provide or change it. Both entry points resolved the order purely from the callback id and trusted it, while the rest of the buyer-facing commands are scoped to the acting user. This brings these two paths in line with that model.
Change
bot/commands.ts— inaddInvoicePHI, return early unlessctx.useris the order'sbuyer_id.bot/start.ts— in thesetinvoice_action, return early unlessctx.useris the order'sbuyer_id.Testing
npx tsc --noEmitpasses.npx eslint bot/commands.ts bot/start.tspasses.Summary by CodeRabbit